﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BotvaBot.RequestChains.Base;
using BotvaBot.RequestChainItems;
using BotvaBot.BusinessLayer.Enums;

namespace BotvaBot.RequestChains
{
    public class PlayTakIlTakChain : BotvaChainBase
    {
        public PlayTakIlTakChain()
            : base()
        { }

        public PlayTakIlTakChain(BotvaChainContext parentContext)
            : base(parentContext)
        { }


        public int MoneyAmount { get; set; }
        public TakIlTakVariants PlayingVariant { get; set; }

        public bool? IsWin
        {
            get
            {
                PlayTakIlTakChainItem playTakIlTakChainItem = Chain.Values
                    .Where(chi => chi.GetType() == typeof(PlayTakIlTakChainItem)).First() as PlayTakIlTakChainItem;
                return playTakIlTakChainItem.IsWin;
            }
        }

        public override void Init()
        {
            base.Init();

            AddItem(new EnterChainItem(), () => !WithInheritedContext);
            AddItem(new LoginChainItem(), () => !WithInheritedContext);
            AddItem(new GotoFermaChainItem());
            AddItem(new GotoTavernaChainItem());
            AddItem(new GotoTakIlTakChainItem());
            AddItem(new PlayTakIlTakChainItem());
            AddItem(new LogoutChainItem(), () => !WithInheritedContext);
        }

        protected override void PrepareRunChain()
        {
            base.PrepareRunChain();

            PlayTakIlTakChainItem playTakIlTakChainItem = Chain.Values
                .Where(chi => chi.GetType() == typeof(PlayTakIlTakChainItem)).First() as PlayTakIlTakChainItem;
            playTakIlTakChainItem.MoneyAmount = MoneyAmount;
            playTakIlTakChainItem.PlayingVariant = PlayingVariant;
        }

    }
}
